/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-25
 * Time: 8:19
 */
public class Test {

    public static  SingalList.ListNode mergeTwoLists(SingalList.ListNode list1, SingalList.ListNode list2) {
        SingalList.ListNode newHead = new SingalList.ListNode(-1);
        SingalList.ListNode tmp = newHead;
        while(list1 != null &&list2 != null){
            if(list1.val < list2.val){
                tmp.next = list1;
                list1=list1.next;
                tmp=tmp.next;
            }else{
                tmp.next = list2;
                list2=list2.next;
                tmp=tmp.next;
            }

        }
        if(list1 != null){
            tmp.next = list1;
        }
        if(list2 != null){
            tmp.next = list2;
        }
        return newHead.next;
    }

    public static void main(String[] args) {
        SingalList singalList1 = new SingalList();
        singalList1.addFirst(0);
        SingalList singalList2 = new SingalList();

        SingalList.ListNode ret = mergeTwoLists(singalList1.head,singalList2.head);
        System.out.println(ret);

    }
    public static void main1(String[] args) {
        SingalList singalList = new SingalList();
//       singalList.creatList();
        singalList.addFirst(1);
        singalList.addFirst(2);
        singalList.addFirst(2);
        singalList.addFirst(4);
        singalList.display();
        singalList.addLast(0);
        singalList.display();
        singalList.addIndex(4,66);
        singalList.display();
        System.out.println(singalList.size());
        boolean ret = singalList.findKey(0);
        System.out.println(ret);
        singalList.remove(0);
        singalList.display();
        singalList.removeAllKey(2);
        singalList.display();
        singalList.clear();
        singalList.display();
    }
}
